<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./libs/PubSub.js"></script>
</head>

<body>
    <button onclick="sendNews()">发布消息</button>
</body>
<script>
    function sendNews() {
        // 发布消息, 通知订阅者
        pubsub.publish('message', {
            title: '新闻标题'
        });
    }
    // 订阅消息message
    pubsub.subscribe('message', function (data) {
        console.log('收到新短消息:', data);
    });

    pubsub.subscribe('message', function (data) {
        console.log('收到新短消息:', data);
    });

    pubsub.subscribe('message', function (data) {
        console.log('收到新短消息:', data);
    });
</script>

</html>